﻿<%@ Page Title="" Language="C#" MasterPageFile="~/presentation/MasterPage.Master"
    AutoEventWireup="true" CodeBehind="HostForm.aspx.cs" Inherits="ISHotel.presentation.HostForm" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div align="left" class="art-blockcontent-body">
        <table>
            <tr>
                <td>
                </td>
                <td align="center">
                    <asp:Label ID="LabelNovyHost" runat="server" Text="Nový host"></asp:Label>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelRodneCislo" runat="server" Text="Rodné číslo:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxRodneCislo" runat="server" MaxLength="10"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorND" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxRodneCislo"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ErrorMessage="Jen čísla!"
                        ValidationExpression="\d+" ControlToValidate="TextBoxRodneCislo">
                    </asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelJmeno" runat="server" Text="Jméno:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxJmeno" runat="server" MaxLength="20"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorJmeno" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxJmeno"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelPrijmeni" runat="server" Text="Přijmení:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxPrijmeni" runat="server" MaxLength="30"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorPrijmeni" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxPrijmeni"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelUlice" runat="server" Text="Ulice:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxUlice" runat="server" MaxLength="50"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorUlice" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxUlice"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelMesto" runat="server" Text="Mesto:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxMesto" runat="server" MaxLength="50"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorMesto" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxMesto"></asp:RequiredFieldValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelPSC" runat="server" Text="PSČ:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxPSC" runat="server" MaxLength="5"></asp:TextBox>
                </td>
                <td>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorPSC" runat="server" ErrorMessage="*"
                        ControlToValidate="TextBoxPSC"></asp:RequiredFieldValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidatorPSC2" runat="server"
                        ErrorMessage="5 číslic!" ValidationExpression=".{5}.*" ControlToValidate="TextBoxPSC">
                    </asp:RegularExpressionValidator>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ErrorMessage="Jen čísla!"
                        ValidationExpression="\d+" ControlToValidate="TextBoxPSC" ValidationGroup="Detail">
                    </asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelTelefon" runat="server" Text="Telefon:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxTelefon" runat="server" MaxLength="9"></asp:TextBox>
                </td>
                <td>
                    <asp:RegularExpressionValidator ID="RegularExpressionValidatorTel" runat="server"
                        ErrorMessage="Jen čísla!" ValidationExpression="\d+" ControlToValidate="TextBoxTelefon">
                    </asp:RegularExpressionValidator>
                </td>
            </tr>
            <tr>
                <td>
                    <asp:Label ID="LabelEmail" runat="server" Text="E-Mail:"></asp:Label>
                </td>
                <td>
                    <asp:TextBox ID="TextBoxEmail" runat="server" MaxLength="50"></asp:TextBox>
                </td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                </td>
                <td align="center">
                    <asp:Button ID="ButtonVlozHost" runat="server" Text="Vlož" OnClick="ButtonVlozHost_Click" />
                </td>
                <td>
                </td>
            </tr>
        </table>
        <asp:ObjectDataSource ID="ODS_ListHost" runat="server" SelectMethod="Select" TypeName="ISHotel.Database.HostTable">
        </asp:ObjectDataSource>
        <br />
        <asp:Label ID="LabelErr" runat="server" Visible="True" ForeColor="Red"></asp:Label>
        <br />
        <br />
        <asp:GridView ID="GridViewHost" runat="server" AutoGenerateColumns="False" DataSourceID="ODS_Host"
            AllowPaging="True" DataKeyNames="rodne_cislo" AllowSorting="False">
            <Columns>
                <asp:TemplateField ShowHeader="False">
                    <ItemTemplate>
                        <asp:ImageButton ID="ImageButtonDel" runat="server" CommandArgument='<%# Eval("rodne_cislo") %>'
                            CommandName="DeleteHost" OnCommand="button_Command" ImageUrl="~/images/delete.jpg"
                            OnClientClick="javascript: return confirm(&apos;Opravdu smazat hosta?&apos;);" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="rodne_cislo" HeaderText="Rodné číslo" SortExpression="rodne_cislo"
                    ItemStyle-HorizontalAlign="Center" ItemStyle-Width="100" />
                <asp:BoundField DataField="jmeno" HeaderText="Jméno" SortExpression="jmeno" ItemStyle-HorizontalAlign="Center" />
                <asp:BoundField DataField="prijmeni" HeaderText="Přijmení" SortExpression="prijmeni"
                    ItemStyle-HorizontalAlign="Center" />
                <asp:BoundField DataField="ulice" HeaderText="Ulice" SortExpression="ulice" ItemStyle-HorizontalAlign="Center" />
                <asp:BoundField DataField="mesto" HeaderText="Město" SortExpression="mesto" ItemStyle-HorizontalAlign="Center" />
                <asp:BoundField DataField="psc" HeaderText="PSČ" SortExpression="psc" ItemStyle-HorizontalAlign="Center" />
                <asp:TemplateField HeaderText="Telefon" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="100">
                    <ItemTemplate>
                        <asp:Literal ID="telefon" runat="server" Text='<%# string.Format("{0:### ### ###}", Int32.Parse(Eval("telefon").ToString())) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="email" HeaderText="E-Mail" SortExpression="email" ItemStyle-HorizontalAlign="Center" />
                <asp:CommandField ShowSelectButton="True" HeaderText="Upravit" SelectImageUrl="../images/pencil.gif"
                    ButtonType="Image" ItemStyle-HorizontalAlign="Center" />
            </Columns>
        </asp:GridView>
        <br />
        <asp:ObjectDataSource ID="ODS_Host" runat="server" SelectMethod="Select" TypeName="ISHotel.Database.HostTable"
            DeleteMethod="Delete">
            <DeleteParameters>
                <asp:Parameter Name="rodne_cislo" Type="String" />
            </DeleteParameters>
        </asp:ObjectDataSource>
        <asp:DetailsView ID="DetailsView1" runat="server" Height="50px" Width="300px" AutoGenerateRows="False"
            DataSourceID="ODS_HostDetail" DataKeyNames="rodne_cislo">
            <Fields>
                <asp:TemplateField HeaderText="Rodné číslo" SortExpression="rodne_cislo">
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("rodne_cislo") %>' ReadOnly="True"></asp:TextBox>
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:Label ID="Label4" runat="server" Text='<%# Bind("rodne_cislo") %>'></asp:Label>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Jméno" SortExpression="jmeno">
                    <ItemTemplate>
                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("jmeno") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("jmeno") %>' MaxLength="20"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorJmenoDetail" runat="server"
                            ErrorMessage="*" ControlToValidate="TextBox2" ValidationGroup="Detail"></asp:RequiredFieldValidator>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Přijmení" SortExpression="prijmeni">
                    <ItemTemplate>
                        <asp:Label ID="Label2" runat="server" Text='<%# Bind("prijmeni") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("prijmeni") %>' MaxLength="20"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorPrijmeniDetail" runat="server"
                            ErrorMessage="*" ControlToValidate="TextBox3" ValidationGroup="Detail"></asp:RequiredFieldValidator>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Ulice" SortExpression="ulice">
                    <ItemTemplate>
                        <asp:Label ID="Label3" runat="server" Text='<%# Bind("ulice") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("ulice") %>' MaxLength="50"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorUliceDetail" runat="server"
                            ErrorMessage="*" ControlToValidate="TextBox4" ValidationGroup="Detail"></asp:RequiredFieldValidator>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Město" SortExpression="mesto">
                    <ItemTemplate>
                        <asp:Label ID="Label5" runat="server" Text='<%# Bind("mesto") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("mesto") %>' MaxLength="50"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorMestoDetail" runat="server"
                            ErrorMessage="*" ControlToValidate="TextBox5" ValidationGroup="Detail"></asp:RequiredFieldValidator>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="PSČ" SortExpression="psc">
                    <ItemTemplate>
                        <asp:Label ID="Label6" runat="server" Text='<%# Bind("psc") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("psc") %>' MaxLength="5"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidatorPSCDetail" runat="server" ErrorMessage="*"
                            ControlToValidate="TextBox6" ValidationGroup="Detail"></asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidatorPSC2Detail" runat="server"
                            ErrorMessage="5 číslic!" ValidationExpression=".{5}.*" ControlToValidate="TextBox6"
                            ValidationGroup="Detail">
                        </asp:RegularExpressionValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidatorPSC3Detail" runat="server"
                            ErrorMessage="Jen čísla!" ValidationExpression="\d+" ControlToValidate="TextBox6"
                            ValidationGroup="Detail">
                        </asp:RegularExpressionValidator>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Telefon" SortExpression="telefon">
                    <ItemTemplate>
                        <asp:Label ID="Label7" runat="server" Text='<%# Bind("telefon") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("telefon") %>' MaxLength="9"></asp:TextBox>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidatorTelDetail" runat="server"
                            ErrorMessage="Jen čísla!" ValidationExpression="\d+" ControlToValidate="TextBox7"
                            ValidationGroup="Detail">
                        </asp:RegularExpressionValidator>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="E-Mail" SortExpression="email">
                    <ItemTemplate>
                        <asp:Label ID="Label8" runat="server" Text='<%# Bind("email") %>'></asp:Label>
                    </ItemTemplate>
                    <EditItemTemplate>
                        <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("email") %>' MaxLength="50"></asp:TextBox>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowEditButton="True" CausesValidation="True" ValidationGroup="Detail" />
            </Fields>
        </asp:DetailsView>
        <asp:ObjectDataSource ID="ODS_HostDetail" runat="server" SelectMethod="Select" UpdateMethod="Update"
            OnUpdated="HostDetail_OnUpdated" DataObjectTypeName="ISHotel.Database.Host" TypeName="ISHotel.Database.HostTable">
            <SelectParameters>
                <asp:ControlParameter PropertyName="SelectedValue" Type="string" Name="rodne_cislo"
                    ControlID="GridViewHost"></asp:ControlParameter>
            </SelectParameters>
        </asp:ObjectDataSource>
    </div>
</asp:Content>
